package com.eci.common.asset.enums;

/**
 * 	请求返回的状态码scode 枚举
 */
public enum ScodeEnum {

	SUCCESS("200", "操作成功"), 
	UNAUTHORIZED("401", "暂未登录或token已经过期"),
	NO_PERMISSION("403", "没有相关权限"),
	NOT_FOUND("404", "请求地址不存在"),
	SERVER_EXCEPTION("500", "服务器内部异常"),
	NULLPOINTER_EXCEPTION("510", "空指针异常"),
	NUMBER_FORMAT_EXCEPTION("511", "数字格式化异常"),
	IO_EXCEPTION("512", "IO异常"),
	ILLEGAL_ARGUMENT_EXCEPTION("513", "非法参数异常"),
	DATA_ACCESS_EXCEPTION("514", "数据存取异常"),
	CONSTRAINT_VIOLATE_EXCEPTION("515", "违法约束条件异常"),
	CALL_INNER_EXCEPTION("516", "微服务之间的服务调用出现异常"), 
	CALL_3RD_EXCEPTION("517", "调用第三方接口出现异常"), 
	ARITHMETIC_EXCEPTION("518", "算术异常"),
	DATA_EXPIRED("519", "过期数据异常"),
	MULTI_CANDIDATE("520", "候选人有多个"),
	UNKNOW_EXCEPTION("555", "其它异常"),
	CUSTOM_EXCEPTION("999", "自定义异常内容");

	private String code;
	private String message;

	ScodeEnum(String code, String message) {
		this.code = code;
		this.message = message;
	}

	public String getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	public static ScodeEnum getByCode(String code) {
		for (ScodeEnum en : ScodeEnum.values()) {
			if (en.code.equals(code)) {
				return en;
			}
		}
		throw new IllegalArgumentException("not found" + code);
	}

}
